package servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import news.dao.impl.NewsDaoImpl;
import news.entity.News;

public class delServlet extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public delServlet() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
			request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		
		int nid = Integer.parseInt( request.getParameter("nid"));
		NewsDaoImpl n =new NewsDaoImpl();
		int l = n.del(nid);
		if(l>0){
		request.getRequestDispatcher("/news/delresult.jsp").forward(request, response);
		}
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
			this.doGet(request, response);
	}

	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occurs
	 */
	public void init() throws ServletException {
		// Put your code here
	}

}
